<?php

/**

 * 订单支付流水管理

 * @author maniac

 */

namespace app\manage\controller;



use app\facade\Orders AS OrdersFacade;

use app\common\model\Orders AS OrdersModel;

use app\facade\UserLogs;



class OrderBank extends Base

{ 


    /**

     * 组合 where 查询条件

     */

    public function where()

    {

        $order_status_id = input('get.order_status_id/d', 0);

        $keywords        = input('get.keywords/s', '');

        $startTime       = input('get.start_time/s', '');

        $endTime         = input('get.end_time/s', '');

        $member_id         = input('get.member_id/s', '');

        $pay_type         = input('get.pay_type/s', 0);


        $where           = [];

        if ($order_status_id) {

            switch ($order_status_id) {

                case 1:

                    // 未付款

                    $where[] = [

                        ['pay_status', 'eq', 1],

                    ];

                    break;

                case 2:

                    // 已付款

                    $where[] = [

                        ['pay_status', 'eq', 2],

                    ];

                    break;

            }
        }
        if($pay_type){
            $where[] = [

                ['pay_type', 'eq', $pay_type],

            ];
        }



        if ($member_id > 0) {

            $where[] = [

                ['userid','eq',$member_id],

            ];

        }

        if ($startTime) {

            $where[] = [

                ['create_time', 'egt', strtotime($startTime)],

            ];

        }

        if ($endTime) {

            $where[] = [

                ['create_time', 'lt', strtotime($endTime)],

            ];

        }

        

        $this->assign('order_status_id', $order_status_id);

        $this->assign('keywords', $keywords);

        $this->assign('startTime', $startTime);

        $this->assign('endTime', $endTime);

        $this->assign('member_id', $member_id);

        $this->assign('pay_type', $pay_type);

        return $where;

    }


    /**

     * 导出 excel

     * @return [type] [description]

     */

    public function export()

    {

        $where = $this->where();

        UserLogs::insertLog(['title' => '导出订单列表']);

        OrdersFacade::export($where);

    }


}

